package lwk.thread.demo;

/**
 * 练习Thread，实现多线程同步下载图片
 */
public class TestThread1Demo extends Thread {

    private String url; // 网络图片地址
    private String name;// 保存的文件名

    public TestThread1Demo(String url,String name) {
        this.url = url;
        this.name = name;
    }

    // 下载图片线程的执行体
    @Override
    public void run() {
        WebDownloader webDownloader = new WebDownloader();
        webDownloader.downloader(url,name);
        System.out.println("下载了文件名为："+name);
    }

    public static void main(String[] args) {

        TestThread1Demo testThread1Demo = new TestThread1Demo("https://vkceyugu.cdn.bspapp.com/VKCEYUGU-866e71ae-1b42-4371-a1ec-45aca1f0aae6/59c04783-d885-4e57-b351-a962569ffb3a.webp", "1.webp");
        TestThread1Demo testThread2Demo = new TestThread1Demo("https://vkceyugu.cdn.bspapp.com/VKCEYUGU-866e71ae-1b42-4371-a1ec-45aca1f0aae6/59c04783-d885-4e57-b351-a962569ffb3a.webp", "2.webp");
        TestThread1Demo testThread3Demo = new TestThread1Demo("https://vkceyugu.cdn.bspapp.com/VKCEYUGU-866e71ae-1b42-4371-a1ec-45aca1f0aae6/59c04783-d885-4e57-b351-a962569ffb3a.webp", "3.webp");

        testThread1Demo.start();
        testThread2Demo.start();
        testThread3Demo.start();

    }
}

